<?php
session_start();
include_once ('inc/class/Util.class.php');
$_SESSION['current_page'] = Util::getPage();
include_once ('inc/class/User.class.php');
include_once ('inc/global/global.inc.php');
include_once ('inc/code/head.php');

if(isset($utente)){
if($utente->id_tipo_user > 1){

?>
<div id="content">
    <div id="table">
        <blockquote>

            <H2>&raquo; Ticket</H2>

            <?php
            //Stampa di tutti i ticket presenti
            $utente = unserialize($_SESSION["user"]);

            $result = mysql_query("SELECT ticket.id, nome, data, descrizione, id_users, mail, stato.nome_stato, nome_priorita
                                   FROM ticket, stato, priorita where ticket.id_stato = stato.id and ticket.id_priorita = priorita.id");

            //        $data = date($row['data'],'d,m,y');

            echo "<table><tr>";
            echo "<th>No.</th>";
            echo "<th>Nome</th>";
            echo "<th>Data</th>";
            echo "<th>Descrizione</th>";
            echo "<th>Id_user</th>";
            echo "<th>Mail</th>";
            echo "<th>Stato</th>";
            echo "<th>Priorit&agrave;</th></tr>";

            while($row = mysql_fetch_array($result)) {
                //$data = split(" ", $row['data']);
                    $data = date("y-m-d",strtotime($row['data']));
                echo "<tr>";
                echo "<td color='green'>".$row['id']."</td>";
                //echo "<td>".$row['data']."</td>";
                echo "<td>".$row['nome']."</td>";
                //echo "<td>".$data[0]."</td>";
                echo "<td>".$data."</td>";
                echo "<td>".$row['descrizione']."</td>";
                echo "<td>".$row['id_users']."</td>";
                echo "<td>".$row['mail']."</td>";
                echo "<td>".$row['nome_stato']."</td>";
                echo "<td>".$row['nome_priorita']."</td>";
                echo "</tr>";
            }

            echo "</table>";
            ?>


        </blockquote>
    </div>
</div>


<?php
    include ('inc/code/footer.php');
    }
    else{
        Util::logoutRedirect();
    }
    }
    else{
        Util::logoutRedirect();
    }
?>